package com.controller;

import com.po.PermissionRoleResourcePO;
import com.result.Result;
import com.service.PermissionRoleResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @Author: chihaojie
 * @Date: 2019/5/29 16:33
 * @Version 1.0
 * @Note
 */
@Api(value = "opermissionRoleResourceApi")
@CrossOrigin
@RestController
@RequestMapping("/permissionRoleResource")
public class PermissionRoleResourceController {

    @Autowired
    private PermissionRoleResourceService permissionRoleResourceService;

    @ApiOperation(value = "新增角色资源关系", httpMethod = "POST", notes = "新增角色资源关系")
    @RequestMapping(value = "/add", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<Boolean> add(@RequestBody PermissionRoleResourcePO permissionRoleResourcePO) {
        return new Result<Boolean>().ok(permissionRoleResourceService.add(permissionRoleResourcePO));
    }

    @ApiOperation(value = "修改角色资源关系", httpMethod = "POST", notes = "修改角色资源关系")
    @RequestMapping(value = "/edit", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<Boolean> edit(@RequestBody PermissionRoleResourcePO permissionRoleResourcePO) {
        return new Result<Boolean>().ok(permissionRoleResourceService.edit(permissionRoleResourcePO));
    }


    @ApiOperation(value = "remove", httpMethod = "GET", notes = "删除角色资源关系")
    @RequestMapping(value = "/remove", method = RequestMethod.GET)
    public Result<Boolean> remove(@RequestParam("id") Long  id) {
        return new Result<Boolean>().ok(permissionRoleResourceService.remove(id));
    }

}
